home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / radiance / simplerd.lha / simplerad / FinalFTP / Prims / mprims.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-26  |  5.4 KB  |  144 lines

  1. /**********************************************************************/
  2. /* mprims.h :                                                         */
  3. /*                                                                    */
  4. /* Meshed primitive types : Keep track of geometry only, and assume   */
  5. /* all primitives fit into unit cube                                  */
  6. /*                                                                    */
  7. /* Copyright (C) 1992, Bernard Kwok                                   */
  8. /* All rights reserved.                                               */
  9. /* Revision 1.0                                                       */
  10. /* May, 1992                                                          */
  11. /**********************************************************************/
  12. #ifndef MPRIMS_H
  13. #define MPRIMS_H
  14.  
  15. #define NIL 0
  16. #define X 0
  17. #define Y 1
  18. #define Z 2
  19. #define W 3
  20.  
  21. #define DEG (M_PI/180.0) /* radians to degrees */
  22. #define MIN_COORD 1.0e-6
  23.  
  24. #define MCONE     10
  25. #define MCUBE     11
  26. #define MCYLINDER 12
  27. #define MSPHERE   13
  28.  
  29. /**********************************************************************/
  30. /* Direction of normals */
  31. /**********************************************************************/
  32. #define NORMAL_OUT 1
  33. #define NORMAL_IN 0
  34. int normal_direction = NORMAL_OUT;
  35.  
  36. /**********************************************************************/
  37. /* Meshed primitive types */
  38. /**********************************************************************/
  39. typedef struct { double x, y, z; } Vector;
  40. typedef struct {
  41.   Vector vertex[4]; /* Polygon vertices */
  42.   Vector normal[4]; /* Polygon normals */
  43.   int size;         /* # of vertices */
  44. } Polygon;
  45.  
  46. typedef struct {
  47.   double vertex[4][3]; /* Polygon vertices */
  48.   double normal[4][3]; /* Polygon normals */
  49.   int size;         /* # of vertices */
  50. } CPolygon;
  51.  
  52. /**********************************************************************/
  53. /* meshed sphere */
  54. /**********************************************************************/
  55. typedef struct {
  56.   Polygon *poly;
  57.   int num_sub;        /* Number subdivisions along lat / long         */
  58.   int num_polys;      /* Number of patchs in mesh                     */
  59.   double r;           /* radius */
  60.   Vector centre;      /* Centre */
  61.   int id;             /* Id */
  62.   char *sid;
  63. } MSphere;
  64.  
  65. /**********************************************************************/
  66. /* Meshed Cone */
  67. /**********************************************************************/
  68. typedef struct {
  69.   Polygon *bpoly;     /* Base polygons */
  70.   Polygon *tpoly;     /* Top polygons (if any) */
  71.   Polygon *spoly;     /* Side polygons */
  72.   double rb, rt, h;   /* Radius and height */
  73.   int num_side_polys; /* # of polys on side of cone */
  74.   int num_disc_polys; /* # of polys on base of cone */
  75.   int id;             /* Id */
  76.   char *sid;
  77. } MCone;
  78.  
  79. /**********************************************************************/
  80. /* meshed cylinder : height is from (0,0,-1) to (0,0,1), and */
  81. /* width is from (-1,0,0) to (1,0,0) */
  82. /**********************************************************************/
  83. typedef struct {
  84.   double r;           /* Radius                                       */
  85.   double h;           /* Height                                       */
  86.   Polygon *spoly;     /* The mesh representing the side of the cyl.   */
  87.   Polygon *tpoly;     /* The mesh representing the top of the cyl.    */
  88.   Polygon *bpoly;     /* The mesh representing the top of the cyl.    */
  89.   int num_sub;        /* Number subdivisions along h and r            */
  90.   int num_side_polys; /* Number of patchs in mesh for sides           */
  91.   int num_disc_polys; /* Number of patchs in mesh for top and bottom  */
  92.   int id;             /* Id */
  93.   char *sid;
  94. } MCylinder;
  95.  
  96. /**********************************************************************/
  97. /* Meshed unit cube */
  98. /**********************************************************************/
  99. typedef struct {
  100.   CPolygon *faces[6]; /* 6 mesh faces                                 */
  101.   int du, dv;         /* Amount of subdivision per face               */
  102.   int num_polys;      /* Number of patchs in mesh                     */
  103.   int id;             /* Id */
  104.   char *sid;
  105. } MCube;
  106.  
  107. /**********************************************************************/
  108. /* Meshed octahedron */
  109. /**********************************************************************/
  110. typedef struct {
  111.   float points[6][3];
  112.   unsigned long colour[6];
  113.   int num_polys;      /* Number of patchs in mesh                     */
  114.   int id;             /* Id */
  115.   char *sid;
  116. } MOctahedron;
  117.  
  118. /**********************************************************************/
  119. /* Meshed torus */
  120. /**********************************************************************/
  121. #define MAX_LATRES 16    /* maximum latitude resolution */
  122. #define MAX_LONRES 36    /* maximum longitude resolution */
  123.  
  124. typedef struct {
  125.   int id;
  126.   char *sid;
  127.   double rad;           /* ratio of major radius to minor radius */
  128.   double scale;         /* shrink object to fit into unit square */
  129.   int latres, longres;
  130.   float points[MAX_LATRES+1][MAX_LONRES+1][3];  /* meshed points, normals, */
  131.   float normals[MAX_LATRES+1][MAX_LONRES+1][3]; /* and colours */
  132.   float colours[MAX_LATRES+1][MAX_LONRES+1][3];
  133.   int num_polys;      /* Number of patchs in mesh                     */
  134. } MTorus;
  135.  
  136. /**********************************************************************/
  137. /* Surface Texture */
  138. /**********************************************************************/
  139. typedef struct {
  140.   double u,v;
  141. } TextureType;
  142.  
  143. #endif MPRIMS_H
  144.